const formatTime = date => {
    const year = date.getFullYear()
    const month = date.getMonth() + 1
    const day = date.getDate()
    const hour = date.getHours()
    const minute = date.getMinutes()
    const second = date.getSeconds()
    
    return `${year}-${month < 10 ? '0' : ''}${month}-${day < 10 ? '0' : ''}${day}`
}

const formatDate = date => {
    const t = date.split('-')
    return `${t[0]}年${t[1]}月${t[2]}日`
}

const formatNumber = n => {
    n = n.toString()
    return n[1] ? n : `0${n}`
}

const getDescInfo = words => {
    var words_list = words.split('')
    var res = ''
    var c = 0
    for (var i = 0; i < words_list.length; i++) {
        res += words_list[i]
        c++
        if (c == 10) {
            c = 0
            res += '\n\t\t\t\t\t\t'
        }
    }
    return res
}

module.exports = {
    formatTime,
    formatDate,
    getDescInfo
}